* Oversight Hearings, Stakeholder Engagement, and Compliance in the Inter-American Court of Human Rights 
* Replication File
* Aníbal Pérez-Liñán & Angie Katherine García Atehortúa, University of Notre Dame
* International Organization
* 3/19/2024

version 18.0
capture: net install psweight, replace from(http://fmwww.bc.edu/RePEc/bocode/p) 
capture: ssc install estout, replace

*** Dataset
use "1_io-hearings.dta", clear 
* Data sources:
*   Inter-American Court of Human Rights: Reparations Dataset, v. 20231109 - https://doi.org/10.7910/DVN/GQ1CAG
*   Data on supervision hearings collected by the authors from Annual Reports and Resolutions - https://www.corteidh.or.cr/
*   V-Dem Dataset, v. 13 - https://v-dem.net/data/the-v-dem-dataset/

*** Descriptives discussed in the text
* Number of cases
preserve
 sort casecode
 collapse (max) hearing, by(casecode)
 di "Number of cases: " _N
restore 
* Number of reparations
preserve
 sort repcode
 collapse (max) hearing hpriv rtype, by(repcode)
 di "Number of reparations: " _N 
 tab hearing  // Number of reparations covered by hearings
 tab hpriv    // Number of reparations covered by private hearings
 // Types of reparations covered by hearings
 label define rt 10 "Restitution" 20 "Rehabilitation" 30 "Satisfaction" 40 "Non-Repetition" 50 "Prosecutions" 61 "Indemnifications" 
 label values rtype rt
 tab rtype hearing, col
 * What percentage of the measures exposed to hearings are "hard" measures?
 gen     hard = 0
 replace hard = 1 if rtype == 20 | rtype == 40 | rtype == 50 
 tab hearing hard, row
restore 
 
 
*** Table 1 - Balance Tests for Propensity Score Matching

  * Create and label reparation type dummies: rty_1 through rty_6
  tabulate rtype, generate(rty_)
  foreach var of varlist * {
  local varlabel : var label `var'
  local newname : subinstr local varlabel "rtype==" "", all
  label variable `var' "`newname'"
  }
  rename rty_1 rty1 // drop reference category
   
  * Step 1: Exact matching: same state, same reparation type, within a 5-year window 
  sort cowcode rtype year
  * Identify state, reparation type, and year clusters
  egen matchid = group(cowcode rtype year)
  sort matchid
  * Which state-type-years had hearings?
  by   matchid: egen match5 = max(hearing)
  drop matchid
  * Include observations in +/- 2-year window 
  sort repcode year
  forvalues i = 1/2 { 
  replace match5 = 1 if match5[_n+`i'] == 1 & repcode==repcode[_n+`i'] // past year
  replace match5 = 1 if match5[_n-`i'] == 1 & repcode==repcode[_n-`i'] // next year
}
  label var match5 "Match by country and reparation type within 5-year window"
  sort ccode year
  tab match5
  
  * Step 2: Propensity score matching: all adjustment variables
  psweight ipw hearing i.civsoc##i.chcompc##(i.rty_*)##c.t  if match5 == 1
    
  * Table 1 - Balance Table 
  dmout civsoc chcompc rty1 rty_* t  using bal_0unw                    , by(hearing) list csv replace decimal(3)  // Balance for unmatched
  dmout civsoc chcompc rty1 rty_* t  using bal_1ipw [pweight = _weight], by(hearing) list csv replace decimal(3)  // Balance for matched


*** Table 2 - Alternative Matching Strategies 
  * Estimate for ATT using IPW
    reg y_full hearing [pweight = _weight] if qualif==1 
    lincom _b[_cons]+_b[hearing]
	  tab hearing if e(sample)  // N treatment and control
  * Robustness tests - Nearest neighbor matching with two matches
    teffects nnmatch (y_full   civsoc   chcompc i.rtype t match5) (hearing), nn(2) atet
	  display "N Treated: `e(n1)'"
	  display "N Control: `e(n0)'"
  * Robustness tests - Exact matching (not able to match exactly on t)
    teffects nnmatch (y_full)                                     (hearing)  if match5 == 1, nn(2) atet e(i.civsoc i.chcompc i.rtype) 
      display "N Treated: `e(n1)'"
	  display "N Control: `e(n0)'"
	
*** Table 3 - DID
reg          y_full   hearing                        period qualif, cluster(repcode) 
 est store m31
reg          y_full   hearing civsoc chcompc i.rtype period qualif, cluster(repcode) 
 est store m32
reg          y_full   hearing civsoc chcompc i.rtype period qualif [pweight = _weight], cluster(repcode) 
 est store m33
didregress(y_full) (hearing)               , group(repcode) time(year) aequations
  est store m34
xtdidregress(y_full           civsoc chcompc) (hearing), group(repcode) time(year) aequations
 est store m35
  didregress(y_full           civsoc chcompc) (hearing) [pweight = _weight], group(repcode) time(year) aequations 
 est store m36

 *Table 3
  esttab m31 m32 m33 /// 
      using "Table_3a.rtf", replace  b(%9.3f) se 	///  
	  	  starlevels(* 0.05) nobase noomit label nodepvars  keep(hearing qualif period civsoc chcompc)  ///
	      title("Table 3a. Effect of Supervision Hearings on Compliance (Difference-in-Differences)")  ///
		  mtitles("Period" "Adjustments" "IPW")   order(hearing qualif period civsoc chcompc)	  
  esttab m34 m35 m36  /// 
      using "Table_3b.rtf", replace  b(%9.3f) se 	///  
	  	  starlevels(* 0.05) nobase noomit label nodepvars  keep(r1vs0.hearing civsoc chcompc) ///
	      title("Table 3b. Effect of Supervision Hearings on Compliance (Difference-in-Differences)")  ///
		  mtitles("Cohort" "Adjustments" "IPW")  

		  
*** Figure 1 - Probe of parallel trends assumption

    reg y_full i.qualif##i.year if year 
	label define qualif 0 "Control" 1 "Treated"
	label values qualif qualif
	margins qualif, at(year=(1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008))
    marginsplot, xline(2007) ytitle("Pr(Compliance)") title("Figure 1. Compliance for Treatment and Control Groups Before 2007", ///
	            size(l)) xsize(7) plotopts(msize(vtiny))
   
*** Table 4 - Duration Models

 ** Model specification 
    global base   i.chcompc i.rtype c.t##c.t##c.t##c.t##c.t##c.t 
    global base2 || cowcode: || casecode:

* Model 4.1 - Baseline
mecloglog y_full i.hearing c.civsoc $base $base2
  est store m41
  margins, dydx(hearing)
  margins hearing
* Model 4.2 - IPW
cloglog y_full i.hearing c.civsoc $base [pweight = _weight], cluster(repcode)
  est store m42
  margins, dydx(hearing)
  margins hearing
* Model 4.3 - Interaction with civil society
cloglog y_full i.hearing##c.civsoc $base [pweight = _weight], cluster(repcode)
  est store m43
  lincom 1.hearing+1.hearing#c.civsoc
  margins hearing, dydx(hearing) at(civsoc= 1)
  margins hearing, at(civsoc= 1)
* Model 4.4 - Baseline, Private hearings
mecloglog y_full i.hpriv c.civsoc $base $base2 
  est store m44
  margins, dydx(hpriv)
  margins hpriv
* Model 4.5 - Interaction, Private hearings
cloglog y_full i.hpriv##c.civsoc $base [pweight = _weight], cluster(repcode)
  est store m45
  lincom 1.hpriv+1.hpriv#c.civsoc
  margins hpriv, dydx(hpriv) at(civsoc= 1)
  margins hpriv, at(civsoc= 1)
* Model 4.6 - Interaction, Private, Continuous moderator
cloglog y_full i.hpriv##c.v2x_frassoc_thick $base [pweight = _weight], cluster(repcode)
  est store m46
  lincom 1.hpriv+1.hpriv#c.v2x_frassoc_thick*.816 // 25th percentile
  lincom 1.hpriv+1.hpriv#c.v2x_frassoc_thick*.871 // 75th percentile
  * Treatment is effective for the upper 2/3 of the sample in freedom of association
  margins hpriv, dydx(hpriv) at(v2x_frassoc_thick=(0.65(.03)0.95))
  marginsplot, yline(0) ciopts(recast(rarea)) plotopts(mcolor(none))
  
*Table 4
  esttab m41 m42 m43 m44 m45 m46 /// 
      using "Table_4.rtf", replace  b(%9.3f) se 	///  
	  	  starlevels(* 0.05) nobase noomit label nodepvars ///
		  order(1.hearing 1.hpriv civsoc v2x_frassoc_thick 1.hearing#c.civsoc 1.hpriv#c.civsoc 1.hpriv#c.v2x_frassoc_thick ///
                1.chcompc 20.rtype 30.rtype 40.rtype 50.rtype 61.rtype ///
				t c.t#c.t c.t#c.t#c.t c.t#c.t#c.t#c.t c.t#c.t#c.t#c.t#c.t c.t#c.t#c.t#c.t#c.t#c.t _cons) ///
	      title("Table 4. Effect of Supervision Hearings on Compliance (Event-History)")  
		  